package com.le.tester.onjava8.l_2_4;

import javax.sound.midi.Soundbank;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 * createTime：2023/2/2 16:21
 * description：可变包装类
 */

class IntValue {
    private int n;

    public IntValue(int n) {
        this.n = n;
    }

    public int getValue() {
        return n;
    }

    public void setValue(int n) {
        this.n = n;
    }

    public void increment() {
        n++;
    }

    @Override
    public String toString() {
        return Integer.toString(n);
    }
}

public class MutableInteger {
    public static void main(String[] args) {
        List<IntValue> v = IntStream.range(0, 10)
                .mapToObj(IntValue::new)
                .collect(Collectors.toList());
        System.out.println(v);
        v.forEach(IntValue::increment);
        System.out.println(v);
    }


}
